home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / fieldent.zip / BOXDEMO.PAS < prev    next >
Pascal/Delphi Source File  |  1993-01-04  |  7KB  |  188 lines

  1. {$M 24000,0,655360}
  2. Program BoxDemo;
  3.  
  4. (*    05/02/1988     J Tal
  5.                      Rollins Medical/Dental Systems
  6.         
  7.                      Public Domain
  8. *)
  9.  
  10. Uses Crt,Funcs,DosBios,Fields;
  11.  
  12.  
  13. VAR
  14.   Cout,Scrf,Scrd: BoxItAryStr;
  15.   vMode,Cout9,Scrf9,Slim,i,w,Scr_type,cursor_field,ii,iii,flen: Integer;
  16.   Colf: IntAry25;
  17.   yn_str,Ed_cur_str,Ed_nor_str,Ed_err_str,Ed_scr_str,cmnd_str,buff_str: st255;
  18.   cols : StrAry25;
  19.   Intens : StrAry4;
  20.   scr_buffer: scr_buffer_type;
  21.   buff_ptr: scr_buffer_ptr;
  22.   rx,ry,rw,rh: BYTE;
  23.  
  24. Procedure InitFields;
  25.  
  26. (*    Sample col variable initialization *)
  27. BEGIN
  28.  
  29.     Case Scr_Type OF
  30.        MonoChrome: begin
  31.                   colf[fore,0] := 7;  colf[back,0] := 0;     (*  Main Text foreground background     *)
  32.                   colf[fore,1] := 1;  colf[back,1] := 0;     (*  Editable field passive colors     *)
  33.                   colf[fore,2] := 0;  colf[back,2] := 7;     (*  Editable field active colors     *)
  34.                   colf[fore,3] := 0;  colf[back,3] := 7;     (*  Editable field in error (reversed)     *)
  35.                      colf[fore,4] := 0;  colf[back,4] := 7;     (*  Main Text in reverse         *)
  36.                     end;
  37.        BlackWhite: begin
  38.                   colf[fore,0] := 7;   colf[back,0] := 0;
  39.                   colf[fore,1] := 0;   colf[back,1] := 2; 
  40.                   colf[fore,2] := 14;  colf[back,2] := 0;
  41.                   colf[fore,3] := 14;  colf[back,3] := 7;
  42.                      colf[fore,4] := 0;   colf[back,4] := 7;
  43.                     end;
  44.             Color: begin
  45.                   colf[fore,0] := 7;    colf[back,0] := 0;
  46.                   colf[fore,1] := 0;    colf[back,1] := 2;
  47.                   colf[fore,2] := 14;   colf[back,2] := 0;
  48.                   colf[fore,3] := 7;    colf[back,3] := 4;
  49.                      colf[fore,4] := 15;   colf[back,4] := 1;
  50.               end;
  51.        else
  52.        end;
  53.  
  54.  
  55. END;
  56.  
  57.  
  58. BEGIN
  59.  
  60.   ClrScr;
  61.  
  62.   InitFrame;
  63.   buff_ptr := @scr_buffer;
  64.  
  65.   vMode := Get_Vmode;
  66.   IF vMode = 7 THEN
  67.      scr_type := MonoChrome
  68.   ELSE begin
  69.      Write('Is you monitor able to display more than 2 colors? (y/n)');
  70.      ReadLn(yn_str);
  71.      IF Upcase(yn_str[1]) = 'Y' THEN
  72.         scr_type := Color
  73.      ELSE
  74.         scr_type := BlackWhite;
  75.  
  76.   END;
  77.  
  78.   InitFields;
  79.   SetIoCol(scr_type,colf,cols,Intens,Ed_cur_Str,Ed_nor_str,Ed_err_str,Ed_scr_str);
  80.   ClrScr;
  81.   gotoxy(1,24);
  82.   Write('Going to form a backdrop and draw the box.  Press <Enter>');
  83.   readln;
  84.   for i := 1 to 24 do begin
  85.     gotoxy(1,i);
  86.     write(rpt(80,ord('▒')));
  87.   end;
  88.  
  89.  
  90.   Gotoxy(2,24); Writeln('<Tab> = next field  <Sh-Tab> = prev field  <Esc> = erase to end   <Ret> = end');
  91.  
  92.  
  93.   (* defining a screen to be output in Cout string array *)
  94.  
  95.     Cout[1] := '             UPDATE THE PHONE TABLE';
  96.     Cout[2] := '─';     
  97.              (* ^- ascii 196 means draw horiz line across box *)
  98.     Cout[3] := '';
  99.     Cout[4] := 'BAUD RATE           2400,*1200,300        ____';  
  100.                                                        (* ^ all _'s denote 
  101.                                                             field position 
  102.                                                             and length *)
  103.     Cout[5] := 'WORD LENGTH         8,*7                  _';
  104.     Cout[6] := 'STOP BITS           *2,1,1                _';
  105.     Cout[7] := 'PARITY              *M,N,E,O              _';
  106.     Cout[8] := '─';
  107.     Cout[9] := 'SPEAKER STATUS      *M1 := ON, M0 := OFF  __';
  108.    Cout[10] := 'DIALING METHOD      *[T]one,[P]ulse       _';
  109.    Cout[11] := 'COM PORT            *2,1                  _';
  110.    Cout[12] := '─';
  111.    Cout[13] := 'AUTO BILLING PHONE NUMBER   _________________________';
  112.    Cout[14] := 'AUTO BILLING PASSWORD       _______________';
  113.    Cout[15] := '─';
  114.    Cout[16] := 'UPDATES PHONE NUMBER      _________________________';
  115.    Cout[17] := 'UPDATES NAME 1            __________';
  116.    Cout[18] := 'UPDATES NAME 2            __________';
  117.    Cout[19] := 'UPDATES PASSWORD 1        __________';
  118.    Cout[20] := 'UPDATES PASSWORD 2        __________';
  119.    Cout9 := 19;
  120.   (* draw screen and return input field definitions in SCRF *)
  121.    Boxit(-1,-1,Cout,Cout9,1,SCRF,SCRF9,FRAME,colf,scr_type,rx,ry,rw,rh,buff_ptr);
  122.   (* paramater breakdown
  123.  
  124.    Boxit(-1,      = screen X pos (-1 = center)
  125.          -1,      = screen Y pos (-1 = center)
  126.          Cout,    = array of strings to define screen.
  127.                     Ascii 196 in string means full horiz bar
  128.                     Underscores (Ascii 95) denotes input field
  129.          Cout9,   = number of cout[]'s defined
  130.          1,       = spac = line spacing between entries
  131.                            Negative values mean line spacing of
  132.                            abs(spac) and each line centered
  133.          SCRF,    = returned field definitions
  134.                      (make sure to dim enough)
  135.          SCRF9,   = number of Scrf[]'s returned
  136.          FRAME,   = array graphic box defs
  137.          colf,    = integer color defs
  138.      scr_type = screen type
  139.       rx,ry,rh,rh = returned box size for subsequent Wput call
  140.      scr_buff_ptr = passed pointer to screen hold buffer which was filled
  141.                     in during call to Boxit.   Used in subsequent Wput call.
  142.  
  143.   *)
  144.  
  145.    slim := SCRF9;
  146.  
  147.    FOR i := 1 TO slim DO begin
  148.        w := fnval(Copy(scrf[i],9,2));
  149.        scrd[i] := spaces(w);
  150.    END;
  151.  
  152.    (* output fields *)
  153.    FOR i := 1 TO slim DO
  154.       field_out(scr_type,colf[fore,0],colf[back,0],scrf[i],scrd[i]);
  155.  
  156.    TextColor(colf[fore,0]);
  157.    TextBackground(colf[back,0]);
  158.  
  159.    cursor_field := 1;
  160.  
  161.    ii := cursor_field;
  162.  
  163.    (* interactive editing begins, ii is control variable *)
  164.    WHILE ii > -2 DO begin   
  165.       (* while return not pressed *)
  166.       cmnd_str := copy(scrf[ii],1,11) + Ed_cur_str;  (* current field *)
  167.       iii := ii;                     (* remember ii in iii cause ii changes *)
  168.       buff_str := scrd[iii];                         (* starting input is field's current contents *)
  169.       field_in(scr_type,colf[fore,0],colf[back,0],cmnd_str,buff_str,flen,ii);  (* field editing *)
  170.       scrd[iii] := buff_str;                         (* has been edited *)
  171.       cmnd_str := copy(scrf[iii],1,11) + Ed_nor_str; (* restore field to orig state *)
  172.       field_out(scr_type,colf[fore,0],colf[back,0],cmnd_str,buff_str);
  173.       if ii > slim then ii := 1;                     (* tab goes to next field, if at end wrap to top *)
  174.       if ii = 0 then ii := slim;                     (* shift-tab goes to prev field, if at top wrap to bottom *)
  175.    END;
  176.  
  177.    gotoxy(1,24);
  178.    Write(' ':80);
  179.    gotoxy(1,24);
  180.    Write('      Going to restore the original backdrop.  Press <Enter>');
  181.    readln;
  182.  
  183.    Wput(rx,ry,rw,rh,buff_ptr);
  184.  
  185.  
  186.  
  187. END.
  188.